<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="zh" xml:lang="zh" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Task Descriptor: Capsule Design</title>
<meta name="uma.type" content="TaskDescriptor">
<meta name="uma.name" content="capsule_design">
<meta name="uma.presentationName" content="Capsule Design">
<meta name="uma.guid" content="_udG5AEocEdqrjq4i3fchvA">
<meta name="element_type" content="TaskDescriptor">
<meta name="filetype" content="description">
<meta name="role" content="">
<link rel="StyleSheet" href="./../../css/default.css" type="text/css">
<script src="./../../scripts/ContentPageResource.js" type="text/javascript" language="JavaScript"></script><script src="./../../scripts/ContentPageSection.js" type="text/javascript" language="JavaScript"></script><script src="./../../scripts/ContentPageSubSection.js" type="text/javascript" language="JavaScript"></script><script src="./../../scripts/ActivityTreeTable.js" type="text/javascript" language="JavaScript"></script><script src="./../../scripts/ProcessElementPage.js" type="text/javascript" language="JavaScript"></script><script src="./../../scripts/ContentPageToolbar.js" type="text/javascript" language="JavaScript"></script><script src="./../../scripts/contentPage.js" type="text/javascript" language="JavaScript"></script><script src="./../../scripts/processElementData.js" type="text/javascript" language="JavaScript"></script><script type="text/javascript" language="JavaScript">
					var defaultQueryStr = '?proc={002674F9-6511-4D15-8623-B761D8C48986}&path={002674F9-6511-4D15-8623-B761D8C48986},{9C683674-97C1-4AEE-8DB0-9514AEFF698E},_udG5AEocEdqrjq4i3fchvA';
					var backPath = './../../';
					var imgPath = './../../images/';
					var nodeInfo=null;
					contentPage.preload(imgPath, backPath, nodeInfo, defaultQueryStr, true, true, false);
				</script>
</head>
<body>
<div id="breadcrumbs"></div>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top">
<div id="page-guid" value="_udG5AEocEdqrjq4i3fchvA"></div>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td class="pageTitle" nowrap="true">Task Descriptor: Capsule Design</td><td width="100%">
<div align="right" id="contentPageToolbar"></div>
</td><td width="100%" class="expandCollapseLink" align="right"><a name="mainIndex" href="./../../index.htm"></a><script language="JavaScript" type="text/javascript" src="./../../scripts/treebrowser.js"></script></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="pageTitleSeparator"><img src="./../../images/shim.gif" alt="" title="" height="1"></td>
</tr>
</table>
<div class="overview">
<table width="97%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50"><img src="./../../images/taskdes_lg_dgm32.gif" alt="" title=""></td><td>
<table class="overviewTable" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">This task describes characteristics of capsule design. </td>
</tr>
<tr>
<td>Based on Method Task: <a href="./../../rup/tasks/capsule_design_BF66E39A.html" guid="{F13C1161-7F17-45E3-A8B7-03944A1FA6E4}">Capsule Design</a></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div class="sectionHeading">Relationships</div>
<div class="sectionContent">
<table class="sectionTable" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<th class="sectionTableHeading" scope="row">Roles</th><td class="sectionTableCell" width="30%"><span class="sectionTableCellHeading">Main:
								</span>
<ul>
<li>
<a href="./../../rup/capabilitypatterns/rup_capsule_designer_8473F52B.html" guid="_UuCQsDnfEdqxANP9kNH4WA">封装体设计员</a>
</li>
</ul>
</td><td class="sectionTableCell" width="30%"><span class="sectionTableCellHeading">Additional:
								</span></td><td class="sectionTableCell"><span class="sectionTableCellHeading">Assisting:
								</span></td>
</tr>
<tr valign="top">
<th class="sectionTableHeading" scope="row">Inputs</th><td class="sectionTableCell" width="30%"><span class="sectionTableCellHeading">Mandatory:
								</span>
<ul>
<li>
<a href="./../../rup/capabilitypatterns/rup_capsule_43C2F219.html" guid="_CQ1sDxi2Edq_uI8xTPML6g">封装体</a>
</li>
<li>
<a href="./../../rup/capabilitypatterns/rup_protocol_17FA0E26.html" guid="_CQ7yqRi2Edq_uI8xTPML6g">协议</a>
</li>
</ul>
</td><td class="sectionTableCell" width="30%"><span class="sectionTableCellHeading">Optional:
								</span>
<ul>
<li>
<a href="./../../rup/capabilitypatterns/rup_event_85FA1BD4.html" guid="_CQ1sCRi2Edq_uI8xTPML6g">事件</a>
</li>
<li>
<a href="./../../rup/capabilitypatterns/rup_signal_B6CA59A5.html" guid="_CQ1sBBi2Edq_uI8xTPML6g">信号</a>
</li>
</ul>
</td><td class="sectionTableCell"><span class="sectionTableCellHeading">External:
								</span>
<ul>
<li>None</li>
</ul>
</td>
</tr>
<tr valign="top">
<th class="sectionTableHeading" scope="row">Outputs</th><td class="sectionTableCell" colspan="3">
<ul>
<li>
<a href="./../../rup/capabilitypatterns/rup_capsule_43C2F219.html" guid="_CQ1sDxi2Edq_uI8xTPML6g">封装体</a>
</li>
<li>
<a href="./../../rup/capabilitypatterns/rup_design_class_7B5C3BC4.html" guid="_CQ1sCBi2Edq_uI8xTPML6g">设计类</a>
</li>
<li>
<a href="./../../rup/capabilitypatterns/rup_protocol_17FA0E26.html" guid="_CQ7yqRi2Edq_uI8xTPML6g">协议</a>
</li>
</ul>
</td>
</tr>
</table>
</div>
<div class="sectionHeading">Steps</div>
<div class="sectionContent">
<table class="sectionTable" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="sectionTableCell">
<div class="stepHeading">Create Ports and Bind to Protocols</div>
<div class="stepContent">
<table class="stepTable" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td><p class="reactive">
    Consider the responsibilities of the capsule, creating an initial set of port classes. These port classes represent the
    'interfaces' to the capsule. Port classes represent the realization of a <a class="elementLinkWithType" href="./../../rup/workproducts/rup_protocol_BEB5FBE1.html" guid="{6E4F4D6F-2934-432C-9335-5537B795F67F}">Artifact: 协议</a>, which in turn represents a set of <b>in</b> and <b>out</b> signals used to communicate with capsules.
</p>
<p class="reactive">
    In creating ports, consider the <a class="elementLinkWithType" href="./../../rup/guidances/checklists/protocol_F7AE51B1.html" guid="1.5025405217477615E-306">Checklist: 协议</a>&nbsp;to
    determine whether the Protocol is appropriate. The port should reflect a singular set of related responsibilities;
    having a similarly scoped protocol enables its re-use across a number of capsules. Once the appropriate protocol is
    selected, bind the port to the appropriate protocol.
</p></td>
</tr>
</table>
</div>
<div class="stepHeading">Validate Capsule Interactions </div>
<div class="stepContent">
<table class="stepTable" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td><p class="reactive">
    Once the ports are bound to protocols, the external behavior of the capsule must be evaluated and validated. Using
    either manual walk-through techniques or automated simulation tools, test the behavior of the capsule by simulating the
    events that will exercise the capsule behavior. Validation will also consider the capsules which interact with the
    capsule under design. Using automated tools, write stub code within the capsule to allow the ports to be tested. When
    errors in protocol or port definition, or in capsule responsibilities are detected, make appropriate changes to
    capsule, port and protocol definitions.
</p></td>
</tr>
</table>
</div>
<div class="stepHeading">Define Capsule State Machine</div>
<div class="stepContent">
<table class="stepTable" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td><p class="reactive">
    Once the capsule ports and protocols have been validated, define the internal behavior of the capsule. The behavior of
    the capsule is defined using a statechart diagram. Reference: <a class="elementLinkWithType" href="./../../rup/guidances/guidelines/statechart_diagram_640B5D0B.html" guid="1.4528459404144188E-304">Guideline: 状态表图</a> . Other general capsule information can be obtained from the <a class="elementLinkWithType" href="./../../rup/guidances/guidelines/capsule_7077C999.html" guid="7.026940817483919E-306">Guideline: 封装体</a> , <a class="elementLinkWithType" href="./../../rup/guidances/checklists/capsule_7BF31788.html" guid="1.2115414799051158E-305">Checklist: 封装体</a>.
</p>
<h4 class="reactive">
    <a id="Define States" name="Define States">Define States</a>
</h4>
<p class="reactive">
    First, identify the states in which the capsule can exist. The states must be unique (a capsule cannot be in two states
    simultaneously) and descriptive. See the appropriate guidelines and checkpoints for more information.
</p>
<h4 class="reactive">
    <a id="Define State Transitions" name="Define State Transitions">Define State Transitions</a>
</h4>
<p class="reactive">
    Once states are defined, consider the transitions between states. Transition code should read like high level
    application pseudo-code, it should consist primarily of real-time operating system service calls e.g., frame services,
    time services, port operations, capsule operations and passive class operations.
</p>
<p class="reactive">
    When adding detail code to a Capsule transition:
</p>
<ul class="reactive">
    <li>
        If the code would be useful in other transitions consider delegating it to a Capsule operation.
    </li>
    <li>
        Consider if the code implements capabilities which conform to the Capsule's responsibility.
    </li>
</ul>
<p class="reactive">
    When defining a Capsule operation:
</p>
<ul class="reactive">
    <li>
        Consider if the function would be useable at any time from any transition in the Capsule, and if whether any of the
        work being done would ever be useful elsewhere in the system. If it is consider delegating it to a passive class
        function.
    </li>
    <li>
        If the code is too application-specific to be stored in a particular Data class, consider creating an additional
        Data class as an abstraction for that code.
    </li>
    <li>
        If the code handles data structure manipulation (e.g., maintaining lists), or performs complex (more than 1 line)
        computations then it should be pushed into a data class.
    </li>
</ul></td>
</tr>
</table>
</div>
<div class="stepHeading">Define Requirements on Passive Classes</div>
<div class="stepContent">
<table class="stepTable" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td><p class="reactive">
    Based on the capsule state machines, examine the passive classes referenced by the capsule. If there are new
    requirements on these classes, change requests need to be generated to effect the required changes. If new classes have
    been identified, the requirements on these classes (most specifically the required operations on them) should be
    gathered together and the classes should be created. These classes will be further described in the <a class="elementLinkWithType" href="./../../rup/tasks/class_design_98F20FF9.html" guid="{27AE0601-2E95-4A6A-8EB3-0A4BA8E5626B}">Task: 类设计</a>.
</p></td>
</tr>
</table>
</div>
<div class="stepHeading">Introduce Capsule Inheritance</div>
<div class="stepContent">
<table class="stepTable" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td><p class="reactive">
    Capsule inheritance is used to implement generalization-specialization, to make use of polymorphism, to reuse
    implementation. The key word here is 'implementation' - it is a technique that is used primarily to re-use the internal
    structure of capsules, not the external behavior of capsules.
</p>
<p class="reactive">
    Inheritance is often misapplied to achieve something that could more easily have been achieved using simpler design
    techniques.
</p>
<h4 class="reactive">
    <b>Using inheritance for generalization-specialization</b>
</h4>
<p class="reactive">
    There are three kinds of inheritance. Listed from lowest complexity (most desirable) to most complex (least desirable),
    they are:
</p>
<ul class="reactive">
    <li>
        <b>Interface inheritance</b> - just inherits ports and protocols, this is the type of inheritance that is most
        desirable
    </li>
    <li>
        <b>Structural inheritance</b> - inherits interface plus structural containment hierarchies (useful for frameworks)
    </li>
    <li>
        <b>Behavioral inheritance</b> - in addition to interface and structural inheritance, also reuses behavioral code
        and state machines
    </li>
</ul>
<p class="reactive">
    Structural and behavioral inheritance pose some problems:
</p>
<ul class="reactive">
    <li>
        The very strong degree of coupling provided by inheritance causes changes to cascade to subclasses when changes are
        made to superclasses.
    </li>
    <li>
        The need to override and delete superclass behavior and structure in subclasses indicates inappropriate use of
        inheritance (usually for tactical code re-use). Re-factoring classes and capsules and appropriate use of delegation
        is a more appropriate strategy.
    </li>
    <li>
        Inheritance means moving design decisions up the class hierarchy, causing undesirable design and compilation
        dependencies.&nbsp;
    </li>
</ul>
<p class="reactive">
    Other problems include:
</p>
<ul class="reactive">
    <li>
        Decisions may not be appropriate in all usage situations.
    </li>
    <li>
        Introducing inheritance actually makes reuse more difficult, since design elements are more tightly coupled.
    </li>
    <li>
        The design becomes more fragile because any new requirement that invalidates the decision causes large problems.
    </li>
    <li>
        The design has to be made extremely flexible to compensate, which is often difficult. This is what makes designing
        reusable frameworks such an effort!
    </li>
</ul>
<p class="reactive">
    All designs containing structure/behavior have decisions and assumptions built in (either explicit or implicit). The
    critical question to ask is: are you absolutely sure that decision/assumption will always be valid? If not, what can
    you do to remove it or make it possible to change?
</p></td>
</tr>
</table>
</div>
<div class="stepHeading">Validate Capsule Behavior</div>
<div class="stepContent">
<table class="stepTable" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td><p class="reactive">
    As a final step, the behavior of the capsule must be evaluated and validated. Using either manual walk-through
    techniques or automated simulation tools, the behavior of the capsule should be tested by simulating the events that
    will exercise the capsule behavior. In addition, the internal structure of the capsule should be validated, ensuring
    that not only the external behavior but also the internal implementation of that behavior is validated. Using automated
    tools, stub code may need to be written to simulate the implementation of passive data classes and external capsules
    with which the capsule interacts. Defects detected should be documented and appropriate changes to capsule definitions
    should be made.
</p></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
<div class="sectionHeading">Properties</div>
<div class="sectionContent">
<table class="sectionTable" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<th class="sectionTableHeading" scope="row" id="property_Multiple Occurrences" abbr="Multiple Occurrences">Multiple Occurrences</th><td class="sectionTableCell" align="left" headers="property_Multiple Occurrences"><img width="20" height="15" alt="" title="" src="./../../images/indent.gif"></td>
</tr>
<tr valign="top">
<th class="sectionTableHeading" scope="row" id="property_Event Driven" abbr="Event Driven">Event Driven</th><td class="sectionTableCell" align="left" headers="property_Event Driven"><img width="20" height="15" alt="" title="" src="./../../images/indent.gif"></td>
</tr>
<tr valign="top">
<th class="sectionTableHeading" scope="row" id="property_Ongoing" abbr="Ongoing">Ongoing</th><td class="sectionTableCell" align="left" headers="property_Ongoing"><img width="20" height="15" alt="" title="" src="./../../images/indent.gif"></td>
</tr>
<tr valign="top">
<th class="sectionTableHeading" scope="row" id="property_Optional" abbr="Optional">Optional</th><td class="sectionTableCell" align="left" headers="property_Optional"><img width="20" height="15" alt="" title="" src="./../../images/indent.gif"></td>
</tr>
<tr valign="top">
<th class="sectionTableHeading" scope="row" id="property_Planned" abbr="Planned">Planned</th><td class="sectionTableCell" align="left" headers="property_Planned"><img width="20" height="15" alt="" title="" src="./../../images/indent.gif"></td>
</tr>
<tr valign="top">
<th class="sectionTableHeading" scope="row" id="property_Repeatable" abbr="Repeatable">Repeatable</th><td class="sectionTableCell" align="left" headers="property_Repeatable"><img width="20" height="15" alt="" title="" src="./../../images/indent.gif"></td>
</tr>
</table>
</div>
<table class="copyright" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="copyright">Copyright &copy; 2008 版权所有 东软集团股份有限公司&nbsp; 联系邮箱:<a href="mailto:tcoe@neusoft.com">tcoe@neusoft.com</a></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
<script language="JavaScript" type="text/javascript">
					contentPage.onload();
					contentPage.processPage.fixDescriptorLinks();
				</script>
</html>
